#include<stdio.h>
#include<string.h>
#include <stdbool.h>


void bit_set(unsigned char *p_data, unsigned char position, bool flag);
int main(void){
		
	unsigned char str[8] = "00000000";
	unsigned char pos = '2';

	bit_set(str, pos, true);
	for(int i = 0; i < 8; i++){
		printf("%c", str[i]);
	}
	printf("\n");
	return 0;
}


void bit_set(unsigned char *p_data, unsigned char position, bool flag){
	int bits = strlen(p_data) - 1 - (position - '0');
	char c;
	if(flag){
		c = '1';
		memcpy(p_data + bits, &c, sizeof(char));
	}else{
		c = '0';
		memcpy(p_data + bits, &c, sizeof(char));
	}
}
